<?php
namespace App\Admin\Repositories;

use App\Admin\Logic\Dhe\DheMachineLogic;
use App\Models\SwtDheMachine;
use Dcat\Admin\Grid;
use Dcat\Admin\Repositories\Repository;
use Illuminate\Pagination\LengthAwarePaginator;

class SwtDheMachineGoods extends Repository
{
    /**
     * 查询表格数据
     *
     * @param Grid\Model $model
     * @return LengthAwarePaginator
     */
    public function get(Grid\Model $model)
    {
        $machine_id = $model -> filter() -> input('machine_id');

        $machine_info = SwtDheMachine::where('machine_id',$machine_id) -> first();

        try {
            $goods_info = DheMachineLogic::getDHEMachineGoods($machine_info -> machine_code);
            return $goods_info;
        } catch (\Exception $e) {
            return [];
        }
    }
}
